//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CLibrary {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CLibrary(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CLibrary obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CLibrary(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CLibrary() {
    this(nelmiscJNI.new_CLibrary__SWIG_0(), true);
  }

  public CLibrary(SWIGTYPE_p_void libHandle, boolean ownership) {
    this(nelmiscJNI.new_CLibrary__SWIG_1(SWIGTYPE_p_void.getCPtr(libHandle), ownership), true);
  }

  public CLibrary(String libName, boolean addNelDecoration, boolean tryLibPath, boolean ownership) {
    this(nelmiscJNI.new_CLibrary__SWIG_2(libName, addNelDecoration, tryLibPath, ownership), true);
  }

  public CLibrary(String libName, boolean addNelDecoration, boolean tryLibPath) {
    this(nelmiscJNI.new_CLibrary__SWIG_3(libName, addNelDecoration, tryLibPath), true);
  }

  public boolean loadLibrary(String libName, boolean addNelDecoration, boolean tryLibPath, boolean ownership) {
    return nelmiscJNI.CLibrary_loadLibrary__SWIG_0(swigCPtr, this, libName, addNelDecoration, tryLibPath, ownership);
  }

  public boolean loadLibrary(String libName, boolean addNelDecoration, boolean tryLibPath) {
    return nelmiscJNI.CLibrary_loadLibrary__SWIG_1(swigCPtr, this, libName, addNelDecoration, tryLibPath);
  }

  public void freeLibrary() {
    nelmiscJNI.CLibrary_freeLibrary(swigCPtr, this);
  }

  public SWIGTYPE_p_void getSymbolAddress(String symbolName) {
    long cPtr = nelmiscJNI.CLibrary_getSymbolAddress(swigCPtr, this, symbolName);
    return (cPtr == 0) ? null : new SWIGTYPE_p_void(cPtr, false);
  }

  public String getLibFileName() {
    return nelmiscJNI.CLibrary_getLibFileName(swigCPtr, this);
  }

  public boolean isLibraryLoaded() {
    return nelmiscJNI.CLibrary_isLibraryLoaded(swigCPtr, this);
  }

  public boolean isLibraryPure() {
    return nelmiscJNI.CLibrary_isLibraryPure(swigCPtr, this);
  }

  public INelLibrary getNelLibraryInterface() {
    long cPtr = nelmiscJNI.CLibrary_getNelLibraryInterface(swigCPtr, this);
    return (cPtr == 0) ? null : new INelLibrary(cPtr, false);
  }

  public static String makeLibName(String baseName) {
    return nelmiscJNI.CLibrary_makeLibName(baseName);
  }

  public static String cleanLibName(String decoratedName) {
    return nelmiscJNI.CLibrary_cleanLibName(decoratedName);
  }

  public static void addLibPaths(Vector_String paths) {
    nelmiscJNI.CLibrary_addLibPaths(Vector_String.getCPtr(paths), paths);
  }

  public static void addLibPath(String path) {
    nelmiscJNI.CLibrary_addLibPath(path);
  }

}
